package cn.hrlly.tao2shou.presenter;

import android.content.Context;

import java.util.List;

import cn.hrlly.tao2shou.biz.SearchCommoditiesBiz;
import cn.hrlly.tao2shou.biz.SearchCommoditiesBizImpl;
import cn.hrlly.tao2shou.listener.OnSearchCommoditiesListener;
import cn.hrlly.tao2shou.view.view_interface.SearchCommoditiesView;

/**
 * User: gengliang
 * Date: 2016-01-29
 * Time: 10:53
 */

public class SearchCommoditiesPresenterImpl implements OnSearchCommoditiesListener,SearchCommoditiesPresenter {

    private SearchCommoditiesBiz searchCommoditiesBiz;
    private SearchCommoditiesView searchCommoditiesView;

    public SearchCommoditiesPresenterImpl(SearchCommoditiesView searchCommoditiesView,Context context){
        this.searchCommoditiesBiz=new SearchCommoditiesBizImpl(this,context);
        this.searchCommoditiesView=searchCommoditiesView;
    }

    //以下的属于searchCommoditiesPresenter
    @Override
    public void searchCommodities() {
        searchCommoditiesBiz.saveHistory(searchCommoditiesView.getAntistop());
        searchCommoditiesView.startActivity();
    }

    @Override
    public void showHistory() {
        searchCommoditiesBiz.showHistory();
    }

    @Override
    public void clearHistory() {
        searchCommoditiesView.clearAntistop();
        searchCommoditiesBiz.clearHistory();
    }

    @Override
    public void closeDataBase() {
        searchCommoditiesBiz.closeDataBase();
    }

    //以下属于onSearchCommoditiesListener
    @Override
    public void showHistoryCommoditiesSucc(List<String> searchList) {
        searchCommoditiesView.showHistoryListView(searchList);
    }
}
